package com.gbiac.toc.event.service.impl;

import com.gbiac.toc.comment.entity.EventCommentEntity;
import com.gbiac.toc.dynamics.entity.EventDynamicsEntity;
import com.gbiac.toc.event.dao.EventExcleDao;
import com.gbiac.toc.event.dao.TimeOutdao;
import com.gbiac.toc.event.entity.EventEntity;
import com.gbiac.toc.event.entity.MyDepart;
import com.gbiac.toc.event.entity.Person;
import com.gbiac.toc.event.service.EventServiceI;
import com.gbiac.toc.eventtype.entity.EventTypeEntity;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.Criteria;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import org.jeecgframework.core.util.DateUtils;
import org.jeecgframework.core.util.MyBeanUtils;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.web.system.pojo.base.TSDepart;
import org.jeecgframework.web.system.pojo.base.TSUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("eventService")
@Transactional
public class EventServiceImpl
  extends CommonServiceImpl
  implements EventServiceI
{
  @Autowired
  private TimeOutdao timeOutdao;
  @Autowired
  private EventExcleDao eventExcleDao;
  
  public <T> void delete(T entity)
  {
    doDelSql((EventEntity)entity);
  }
  
  public void addMain(EventEntity event, List<EventDynamicsEntity> eventDynamicsList, List<EventCommentEntity> eventCommentList)
  {
    save(event);
    for (EventDynamicsEntity eventDynamics : eventDynamicsList)
    {
      eventDynamics.setEventId(event.getId());
      save(eventDynamics);
    }
    for (EventCommentEntity eventComment : eventCommentList)
    {
      eventComment.setEventId(event.getId());
      save(eventComment);
    }
    doAddSql(event);
  }
  
  public void updateMain(EventEntity event, List<EventDynamicsEntity> eventDynamicsList, List<EventCommentEntity> eventCommentList)
  {
    if (StringUtil.isNotEmpty(event.getId())) {
      try
      {
        EventEntity temp = (EventEntity)findUniqueByProperty(EventEntity.class, "id", event.getId());
        MyBeanUtils.copyBeanNotNull2Bean(event, temp);
        saveOrUpdate(temp);
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    } else {
      saveOrUpdate(event);
    }
    List<String> eventDynamicsIds = new ArrayList();
    List<String> eventCommentsIds = new ArrayList();
    for (EventDynamicsEntity eventDynamicsEntity : eventDynamicsList)
    {
      if (StringUtils.isBlank(eventDynamicsEntity.getId()))
      {
        eventDynamicsEntity.setId(null);
        eventDynamicsEntity.setEventId(event.getId());
        saveOrUpdate(eventDynamicsEntity);
      }
      eventDynamicsIds.add(eventDynamicsEntity.getId());
    }
    for (EventCommentEntity eventCommentEntity : eventCommentList)
    {
      if (StringUtils.isBlank(eventCommentEntity.getId()))
      {
        eventCommentEntity.setId(null);
        eventCommentEntity.setEventId(event.getId());
        saveOrUpdate(eventCommentEntity);
      }
      eventCommentsIds.add(eventCommentEntity.getId());
    }
    DetachedCriteria dynamicsdetachedCriteria = DetachedCriteria.forClass(EventDynamicsEntity.class);
    dynamicsdetachedCriteria.add(Restrictions.eq("eventId", event.getId()));
    if (eventDynamicsIds.size() > 0) {
      dynamicsdetachedCriteria.add(Restrictions.not(Restrictions.in("id", eventDynamicsIds)));
    }
    List<EventDynamicsEntity> eventDynamicsDeleteList = dynamicsdetachedCriteria.getExecutableCriteria(getSession()).list();
    for (EventDynamicsEntity eventDynamicsEntity : eventDynamicsDeleteList) {
      getSession().delete(eventDynamicsEntity);
    }
    DetachedCriteria commentdetachedCriteria = DetachedCriteria.forClass(EventCommentEntity.class);
    commentdetachedCriteria.add(Restrictions.eq("eventId", event.getId()));
    if (eventCommentsIds.size() > 0) {
      commentdetachedCriteria.add(Restrictions.not(Restrictions.in("id", eventCommentsIds)));
    }
    List<EventCommentEntity> eventCommentDeleteList = commentdetachedCriteria.getExecutableCriteria(getSession()).list();
    for (EventCommentEntity eventCommentEntity : eventCommentDeleteList) {
      getSession().delete(eventCommentEntity);
    }
    doUpdateSql(event);
  }
  
  public void delMain(EventEntity event)
  {
    delete(event);
  }
  
  public boolean doAddSql(EventEntity t)
  {
    return true;
  }
  
  public boolean doUpdateSql(EventEntity t)
  {
    return true;
  }
  
  public boolean doDelSql(EventEntity t)
  {
    String sqlEnhance_1 = "update toc_event  set  isdelete = 1 where id= ?";
    executeSql(sqlEnhance_1, new Object[] { t.getId() });
    return true;
  }
  
  public String replaceVal(String sql, EventEntity t)
  {
    sql = sql.replace("#{id}", String.valueOf(t.getId()));
    sql = sql.replace("#{number}", String.valueOf(t.getNumber()));
    sql = sql.replace("#{title}", String.valueOf(t.getTitle()));
    sql = sql.replace("#{create_name}", String.valueOf(t.getCreateName()));
    sql = sql.replace("#{create_date}", String.valueOf(t.getCreateDate()));
    sql = sql.replace("#{detailedarea}", String.valueOf(t.getDetailedarea()));
    sql = sql.replace("#{update_date}", String.valueOf(t.getUpdateDate()));
    sql = sql.replace("#{sys_org_code}", String.valueOf(t.getSysOrgCode()));
    sql = sql.replace("#{sys_company_code}", String.valueOf(t.getSysCompanyCode()));
    sql = sql.replace("#{event_type}", String.valueOf(t.getEventType()));
    sql = sql.replace("#{before_pic1}", String.valueOf(t.getBeforePic1()));
    sql = sql.replace("#{before_pic2}", String.valueOf(t.getBeforePic2()));
    sql = sql.replace("#{before_pic3}", String.valueOf(t.getBeforePic3()));
    sql = sql.replace("#{after_pic1}", String.valueOf(t.getAfterPic1()));
    sql = sql.replace("#{after_pic2}", String.valueOf(t.getAfterPic2()));
    sql = sql.replace("#{after_pic3}", String.valueOf(t.getAfterPic3()));
    sql = sql.replace("#{contact}", String.valueOf(t.getContact()));
    sql = sql.replace("#{content}", String.valueOf(t.getContent()));
    sql = sql.replace("#{area}", String.valueOf(t.getArea()));
    sql = sql.replace("#{status}", String.valueOf(t.getStatus()));
    sql = sql.replace("#{check_status}", String.valueOf(t.getCheckStatus()));
    sql = sql.replace("#{depart}", String.valueOf(t.getDepart()));
    sql = sql.replace("#{isdelete}", String.valueOf(t.getIsdelete()));
    sql = sql.replace("#{UUID}", UUID.randomUUID().toString());
    return sql;
  }
  
  public boolean doAuditingyesSql(EventEntity t)
  {
    if (t.getStatus().intValue() == 1)
    {
      String sqlEnhance_1 = "update toc_event set check_status = 1 ,status = 2 where id = ?";
      executeSql(sqlEnhance_1, new Object[] { t.getId() });
      EventDynamicsEntity dynamicsEntity = new EventDynamicsEntity();
      String time = DateUtils.formatTime(new Date());
      String name = ResourceUtil.getSessionUser().getRealName();
      dynamicsEntity.setDycontent(time + name + "审核通过,事件进入待指派.");
      dynamicsEntity.setEventId(t.getId());
      save(dynamicsEntity);
      return true;
    }
    if (t.getStatus().intValue() == 5)
    {
      String sqlEnhance_1 = "update toc_event set check_status = 1 ,status = 6 where id = ?";
      executeSql(sqlEnhance_1, new Object[] { t.getId() });
      EventDynamicsEntity dynamicsEntity = new EventDynamicsEntity();
      String time = DateUtils.formatTime(new Date());
      String name = ResourceUtil.getSessionUser().getRealName();
      dynamicsEntity.setDycontent(time + name + "审核通过,事件进入toc审核中.");
      dynamicsEntity.setEventId(t.getId());
      save(dynamicsEntity);
    }
    return true;
  }
  
  public boolean doAuditingnoSql(EventEntity t)
  {
    EventDynamicsEntity dynamicsEntity = new EventDynamicsEntity();
    String time = DateUtils.formatTime(new Date());
    TSUser user = ResourceUtil.getSessionUser();
    String name = user.getRealName();
    String depart = user.getCurrentDepart().getDepartname();
    if (t.getStatus().intValue() == 1)
    {
      String sqlEnhance_1 = "update toc_event set check_status = 0,status = 7 where id = ?";
      executeSql(sqlEnhance_1, new Object[] { t.getId() });
      dynamicsEntity.setDycontent(time + depart + name + "驳回,事件关闭");
      dynamicsEntity.setEventId(t.getId());
      dynamicsEntity.setCreateDate(new Date());
      save(dynamicsEntity);
      return true;
    }
    if (t.getStatus().intValue() == 5)
    {
      String sqlEnhance_1 = "update toc_event set check_status = 0,status = 4 where id = ?";
      executeSql(sqlEnhance_1, new Object[] { t.getId() });
      dynamicsEntity.setDycontent(time + depart + name + "驳回,重新进入处理中.");
      dynamicsEntity.setEventId(t.getId());
      save(dynamicsEntity);
    }
    return true;
  }
  
  public String checkStatus(Integer status)
  {
    Session session = getSession();
    String query = (String)session.createSQLQuery("select status_name from toc_event_status where id = " + status).list().get(0);
    return query;
  }
  
  public boolean doOverSql(EventEntity t)
  {
    EventDynamicsEntity dynamicsEntity = new EventDynamicsEntity();
    String time = DateUtils.formatTime(new Date());
    TSUser user = ResourceUtil.getSessionUser();
    String name = user.getRealName();
    String depart = user.getCurrentDepart().getDepartname();
    String sqlEnhance_1 = "update toc_event set status = 7 where id = ?";
    executeSql(sqlEnhance_1, new Object[] { t.getId() });
    dynamicsEntity.setDycontent(time + depart + "的" + name + "关闭事件.");
    dynamicsEntity.setEventId(t.getId());
    save(dynamicsEntity);
    return true;
  }
  
  public boolean doTocauditingyesSql(EventEntity t)
  {
    String sqlEnhance_1 = "update toc_event set status = 7 where id = ?";
    executeSql(sqlEnhance_1, new Object[] { t.getId() });
    EventDynamicsEntity dynamicsEntity = new EventDynamicsEntity();
    String time = DateUtils.formatTime(new Date());
    TSUser user = ResourceUtil.getSessionUser();
    String name = user.getRealName();
    String depart = user.getCurrentDepart().getDepartname();
    dynamicsEntity.setDycontent(time + depart + "-" + name + "审核通过,事件关闭.");
    dynamicsEntity.setEventId(t.getId());
    save(dynamicsEntity);
    return true;
  }
  
  public boolean doTocauditingnoSql(EventEntity t)
  {
    String sqlEnhance_1 = "update toc_event set status = 4 where id = ?";
    executeSql(sqlEnhance_1, new Object[] { t.getId() });
    EventDynamicsEntity dynamicsEntity = new EventDynamicsEntity();
    String time = DateUtils.formatTime(new Date());
    TSUser user = ResourceUtil.getSessionUser();
    String name = user.getRealName();
    String depart = user.getCurrentDepart().getDepartname();
    dynamicsEntity.setDycontent(time + depart + "-" + name + "驳回,重新进入处理中.");
    dynamicsEntity.setEventId(t.getId());
    save(dynamicsEntity);
    return true;
  }
  
  public void saomiao()
  {
    this.timeOutdao.saomiao();
  }
  
  public String getName(String id)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT realname FROM t_s_base_user WHERE id = '" + id + "'");
    List list = query.list();
    if ((list != null) && (list.get(0) != null)) {
      return (String)list.get(0);
    }
    return "";
  }
  
  public ArrayList<String> getImei(String departId)
  {
    ArrayList<String> list = new ArrayList();
    
    ArrayList<String> role = getRole(departId);
    for (String str : role)
    {
      String imei = this.timeOutdao.getImei(str);
      if (StringUtils.isNotBlank(imei)) {
        list.add(imei);
      }
    }
    return list;
  }
  
  public ArrayList<Person> getPerson(String depart)
  {
    ArrayList<Person> persons = new ArrayList();
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT user_id FROM t_s_user_org WHERE org_id = '" + depart + "'");
    List list = query.list();
    if (!list.isEmpty())
    {
      Object[] ids = query.list().toArray();
      for (int i = 0; i < ids.length; i++)
      {
        Person p = new Person();
        p.setId((String)ids[i]);
        SQLQuery query2 = session.createSQLQuery("SELECT user.realname FROM t_s_base_user user WHERE user.id = '" + ids[i] + "'" + " AND user.id  in (SELECT tu.userid from t_s_role_user tu where tu.roleid in (SELECT tr.ID FROM t_s_role tr where tr.rolecode not in ('admanger','admin')))");
        
        List list2 = query2.list();
        if (!list2.isEmpty())
        {
          Object[] names = list2.toArray();
          p.setName((String)names[0]);
          persons.add(p);
        }
      }
    }
    return persons;
  }
  
  public ArrayList<EventTypeEntity> getTocEventType(String parentId)
  {
    EventTypeEntity eventTypeEntity = new EventTypeEntity();
    eventTypeEntity.setId("");
    eventTypeEntity.setName("---请选择---");
    
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(EventTypeEntity.class);
    detachedCriteria.add(Restrictions.eq("isDelete", Integer.valueOf(0)));
    detachedCriteria.add(Restrictions.eq("fatherId", parentId));
    detachedCriteria.addOrder(Order.asc("orderBy"));
    
    List<EventTypeEntity> EventTypeLists = detachedCriteria.getExecutableCriteria(getSession()).list();
    EventTypeLists.add(0, eventTypeEntity);
    
    return (ArrayList)EventTypeLists;
  }
  
  public List<EventTypeEntity> getEventTypeLists(DetachedCriteria detachedCriteria)
  {
    return detachedCriteria.getExecutableCriteria(getSession()).list();
  }
  
  public String sendRecipient(String pid)
  {
    String imei = this.timeOutdao.getImei(pid);
    return imei;
  }
  
  public String getNodo()
  {
    Session session = getSession();
    String mesage = "";
    
    SQLQuery query = session.createSQLQuery("SELECT COUNT(id) FROM toc_event WHERE STATUS=2  AND isdelete=0");
    
    SQLQuery query2 = session.createSQLQuery("SELECT COUNT(id) FROM toc_event WHERE STATUS=6 AND isdelete=0");
    
    SQLQuery comingOutofTimeQuery = session.createSQLQuery("SELECT COUNT(id) FROM toc_event WHERE (STATUS < 7 or STATUS = 8) AND isdelete=0 AND timeout_status = 2");
    
    SQLQuery overTimeQuery = session.createSQLQuery("SELECT COUNT(id) FROM toc_event WHERE (STATUS < 7 or STATUS = 8) AND isdelete=0 AND timeout_status = 3");
    List list = query.list();
    List list2 = query2.list();
    List comingOutofTimeList = comingOutofTimeQuery.list();
    List overTimeList = overTimeQuery.list();
    if (!list.isEmpty())
    {
      BigInteger zhipai = (BigInteger)list.get(0);
      mesage = "待指派事件:\t\t" + zhipai;
    }
    if (!list2.isEmpty())
    {
      BigInteger shenhe = (BigInteger)list2.get(0);
      mesage = mesage + ",待审核事件:\t\t" + shenhe;
    }
    if (!comingOutofTimeList.isEmpty())
    {
      BigInteger comingOutofTimeCount = (BigInteger)comingOutofTimeList.get(0);
      mesage = mesage + ",即将超时事件:\t\t" + comingOutofTimeCount;
    }
    if (!overTimeList.isEmpty())
    {
      BigInteger overTimeCount = (BigInteger)overTimeList.get(0);
      mesage = mesage + ",已超时事件:\t\t" + overTimeCount;
    }
    return mesage;
  }
  
  public ArrayList<String> getAllImei()
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT imei FROM toc_app_imei");
    ArrayList<String> list = (ArrayList)query.list();
    return list;
  }
  
  public void closeEvent(String id)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("UPDATE toc_event SET status = 7 WHERE id = ?");
    query.setString(0, id);
    query.executeUpdate();
  }
  
  public boolean isExists(String recipient)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT id FROM toc_index WHERE user_id = '" + recipient + "'");
    List list = query.list();
    if (!list.isEmpty())
    {
      Integer id = Integer.valueOf(list.get(0).toString());
      if (id.intValue() > 0) {
        return true;
      }
    }
    return false;
  }
  
  public int getIndex(String recipient, String string)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT " + string + " FROM toc_index WHERE user_id ='" + recipient + "'");
    List list = query.list();
    if (!list.isEmpty())
    {
      int index = ((Integer)list.get(0)).intValue();
      return index;
    }
    return 0;
  }
  
  public void updateIndex(String recipient, String string, int index)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("UPDATE toc_index SET " + string + " = " + (index + 1) + " WHERE user_id='" + recipient + "'");
    query.executeUpdate();
  }
  
  public void addIndex(String recipient, String string)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("INSERT toc_index(" + string + ",user_id) VALUES(1,?)");
    query.setString(0, recipient);
    query.executeUpdate();
  }
  
  public ArrayList<String> getAllUser()
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT id FROM t_s_base_user");
    ArrayList<String> list = (ArrayList)query.list();
    return list;
  }
  
  public ArrayList<String> getRole(String departId)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT USER.id FROM t_s_base_user USER LEFT JOIN t_s_user_org org ON USER.id = org.user_id  WHERE USER.id in (SELECT tu.userid from t_s_role_user tu where tu.roleid in (SELECT tr.ID FROM t_s_role tr where tr.rolecode ='admanger')) AND org.org_id = :orgId");
    
    query.setString("orgId", departId);
    ArrayList<String> list = (ArrayList)query.list();
    return list;
  }
  
  public String getZpTotal(String before)
  {
    Session session = getSession();
    String mesage = "";
    
    SQLQuery query2 = session.createSQLQuery("SELECT live FROM toc_live WHERE page ='指派' ");
    List list2 = query2.list();
    if (!list2.isEmpty())
    {
      String live = list2.get(0).toString();
      int parseInt = Integer.parseInt(live);
      if (parseInt > 0) {
        return before;
      }
    }
    SQLQuery query = session.createSQLQuery("SELECT COUNT(id) FROM toc_event WHERE STATUS=2  AND isdelete=0");
    List list = query.list();
    if (!list.isEmpty())
    {
      BigInteger zhipai = (BigInteger)list.get(0);
      mesage = "" + zhipai;
    }
    return mesage;
  }
  
  public String getShTotal(String before)
  {
    Session session = getSession();
    String mesage = "";
    
    SQLQuery query2 = session.createSQLQuery("SELECT live FROM toc_live WHERE page ='审核' ");
    List list2 = query2.list();
    if (!list2.isEmpty())
    {
      String live = list2.get(0).toString();
      int parseInt = Integer.parseInt(live);
      if (parseInt >= 0) {
        return before;
      }
    }
    SQLQuery query3 = session.createSQLQuery("SELECT COUNT(id) FROM toc_event WHERE STATUS=6 AND isdelete=0");
    List list3 = query3.list();
    if (!list3.isEmpty())
    {
      BigInteger shenhe = (BigInteger)list3.get(0);
      mesage = "" + shenhe;
    }
    return mesage;
  }
  
  public ArrayList<MyDepart> getDepart()
  {
    ArrayList<MyDepart> departs = new ArrayList();
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT id,departname FROM t_s_depart");
    List<Object[]> list = query.list();
    for (Object[] objects : list)
    {
      MyDepart myDepart = new MyDepart(objects[0].toString(), objects[1].toString());
      departs.add(myDepart);
    }
    return departs;
  }
  
  public String isNumber(String number)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT COUNT(*) FROM toc_event WHERE number = ?");
    query.setString(0, number);
    List list = query.list();
    if (list.isEmpty()) {
      return "1";
    }
    BigInteger num = (BigInteger)list.get(0);
    String string = num.toString();
    int count = Integer.parseInt(string);
    if (count >= 1) {
      return "0";
    }
    return "1";
  }
  
  public ArrayList<String> seachName(String recipient)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT id FROM t_s_base_user WHERE realname LIKE ?");
    query.setString(0, "%" + recipient + "%");
    ArrayList<String> list = (ArrayList)query.list();
    return list;
  }
  
  public void fresh()
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("UPDATE toc_live SET live = live-5 WHERE 1 = 1 ");
    query.executeUpdate();
  }
  
  public void updateLive(String parm)
  {
    Session session = getSession();
    if ("zp".equals(parm))
    {
      SQLQuery query = session.createSQLQuery("UPDATE toc_live SET live = 10 WHERE page = ?");
      parm = "指派";
      query.setString(0, parm);
      query.executeUpdate();
    }
    else
    {
      SQLQuery query = session.createSQLQuery("UPDATE toc_live SET live = 10 WHERE 1 = 1 ");
      query.executeUpdate();
    }
  }
  
  public String isNumberadd(String number)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT id FROM toc_event WHERE number = ?");
    query.setString(0, number);
    List list = query.list();
    if (list.isEmpty()) {
      return "1";
    }
    return "0";
  }
  
  public String getRealName(String pid)
  {
    Session session = getSession();
    SQLQuery query = session.createSQLQuery("SELECT realname FROM t_s_base_user WHERE id = ?");
    query.setString(0, pid);
    List list = query.list();
    if (!list.isEmpty())
    {
      String name = (String)list.get(0);
      return name;
    }
    return "";
  }
  
  public List<EventDynamicsEntity> getEventDynamicsListByEventIds(DetachedCriteria detachedCriteria)
  {
    return detachedCriteria.getExecutableCriteria(getSession()).list();
  }
  
  public void doChangeDept(EventEntity event, List<EventDynamicsEntity> eventDynamicsList, List<EventCommentEntity> eventCommentList)
    throws Exception
  {
    EventEntity reposityEntity = (EventEntity)getEntity(EventEntity.class, event.getId());
    
    reposityEntity.setStatus(Integer.valueOf(3));
    reposityEntity.setRecipient(null);
    reposityEntity.setChangeDeptTime(new Timestamp(System.currentTimeMillis()));
    
    reposityEntity.setTimeoutStatus(Integer.valueOf(1));
    
    reposityEntity.setBudgetTime(null);
    
    reposityEntity.setDepart(event.getDepart());
    for (EventDynamicsEntity eventDynamicsEntity : eventDynamicsList)
    {
      eventDynamicsEntity.setEventId(event.getId());
      save(eventDynamicsEntity);
    }
    for (EventCommentEntity eventCommentEntity : eventCommentList)
    {
      eventCommentEntity.setEventId(event.getId());
      save(eventCommentEntity);
    }
    doUpdateSql(event);
  }
  
  public List<EventCommentEntity> getEventCotentListByEventIds(DetachedCriteria detachedCriteria)
  {
    return detachedCriteria.getExecutableCriteria(getSession()).list();
  }
}
